package com.ruoyi.repast.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.repast.entity.BPrivateRoom;
import com.ruoyi.repast.service.BPrivateRoomService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 餐饮管理控制器
 * @author zhangjialu
 * @date 2021/7/31 下午11:25
 */
@Controller
@RequestMapping("/repast/bPrivateRoom")
public class BPrivateRoomController extends BaseController {

    private String prefix = "repast/bPrivateRoom";


    /**
     * 包间管理service接口
     */
    @Autowired
    private BPrivateRoomService bPrivateRoomService;


    /**
     * 列表页面
     * @return
     */
    @GetMapping()
    public String list()
    {
        return prefix + "/bPrivateRoomList";
    }



    /**
     * 新增包间
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/bPrivateRoomForm";
    }

    /**
     * 新增保存包间
     */
    @RequiresPermissions("monitor:job:add")
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@Validated BPrivateRoom bPrivateRoom)
    {
        AjaxResult ajaxResult= bPrivateRoomService.saveBPrivateRoom(bPrivateRoom);
        return ajaxResult;
    }

    /**
     * 修改包间页面
     */
    @GetMapping("/edit/{bPrivateRoomId}")
    public String edit(@PathVariable("bPrivateRoomId") String bPrivateRoomId, ModelMap mmap)
    {
        mmap.put("bPrivateRoom", bPrivateRoomService.selectJobById(bPrivateRoomId));
        return prefix + "/bPrivateRoomEdit";
    }

    /**
     * 包间信息更新
     * @param bPrivateRoom
     * @return
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult edit(@Validated BPrivateRoom bPrivateRoom)
    {
        AjaxResult ajaxResult= bPrivateRoomService.saveBPrivateRoom(bPrivateRoom);
        return ajaxResult;
    }


    /**
     * 数据删除
     * @param ids
     * @return
     */
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        bPrivateRoomService.deleteBPrivateRoomByIds(ids);
        return success();
    }



    /**
     * 分页数据查询
     * @param bPrivateRoom
     * @return
     */
    @PostMapping("/listPage")
    @ResponseBody
    public Object listPage(BPrivateRoom bPrivateRoom,Integer pageNum,Integer pageSize)
    {
        TableDataInfo list = bPrivateRoomService.listPage(bPrivateRoom,pageNum,pageSize);
        return list;
    }


}
